fix(preact): stale prop updater keeps writing to the DOM after all signal props are removed - #948
Merged
Merged
Conversation
…rops The DIFFED hook only disposed stale updaters inside the vnode.__np branch, so a re-render that carried no signal props at all skipped disposal entirely. The orphaned updater effect kept writing the old signal's values into the DOM until unmount.
🦋 Changeset detectedLatest commit: 60f50ca The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for preact-signals-demo ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
Size Change: +24 B (+0.01%) Total Size: 187 kB 📦 View Changed
ℹ️ View Unchanged
|
marvinhagemeister
approved these changes
Jul 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
In the
DIFFEDhook, the loop that disposes updaters for props no longer bound to a signal is nested insideif (props)whereprops = vnode.__np. When a re-render passes no signal props for the element — e.g.<input value={editing ? draft : "saved"} />flipping to the plain-string branch —vnode.__npisundefinedand the whole block, including disposal, is skipped. The oldPropertyUpdatereffect stays subscribed to the previous signal and keeps writing its values straight into the DOM property, clobbering whatever Preact rendered, until the element unmounts.Fix
Run the disposal pass over
dom._updatersunconditionally, treating a missingvnode.__npthe same as "no props are signal-bound anymore", and only lazily create the updaters map when the new render actually has signal props. The regression test renders<input value={signal} />, re-renders with a plain string, then writes to the signal and asserts the DOM keeps the rendered value.Note: this PR was authored by Claude and @JoviDeCroock.